<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
</style>

<body>
    <div id="myDiv" class="bd" title="Body Text" data-appid="12345" data-myname="whmk" style="height:800px;">
        div这个是用来测试
    </div>
    <form action="#" id="myForm">
        <input type="text" />
    </form>
</body>
<script>
    window.onload = function () {
        (function () {
            let div = document.getElementById("myDiv");
            let appId = div.dataset.appid;
            let myName = div.dataset.myname;
            console.log(`自定义属性appId:${appId},myName:${myName}`);

            div.dataset.appId = "56789";
            div.dataset.myName = "JJJ";
            console.log(div.dataset.appId + "," + div.dataset.myName);

            //scrollToTop(div);
            div.onclick=function(){
                scrollToTop(div);
            };
        })();
        (function () {
            let myForm = document.getElementById("myForm");
            myForm.scrollIntoView(false);
            console.log(myForm);
        })();

        function scrollToTop(element){
            console.log(element.scrollTop);
            if(element.scrollTop!=0){
                element.scrollTop=0;
            }
        }
    }
</script>



</html>